//
//  HLTqupinglunTableViewController.m
//  huiliantong
//
//  Created by hlt on 15/10/7.
//  Copyright © 2015年 hlt. All rights reserved.
//

#import "HLTqupinglunTableViewController.h"
#import "EYInputPopupView.h"
#import "HLTpinglunTableViewController.h"
@interface HLTqupinglunTableViewController ()<MONActivityIndicatorViewDelegate>



@property NSString *pingluninfo;


@property (weak, nonatomic) IBOutlet UILabel *info;


@end

@implementation HLTqupinglunTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
    
    self.dengji.show_star=1;
    
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section==0) {
        if (indexPath.row==1) {
            
            [EYInputPopupView popViewWithTitle:@"请输入评价的内容" contentText:nil
                                          type:EYInputPopupView_Type_single_line_text
                                   cancelBlock:^{
                                       
                                   } confirmBlock:^(UIView *view, NSString *text) {
                                       
                                       self.info.text=text;
                                   } dismissBlock:^{
                                       
                                   }];
        }
    }
}

- (IBAction)tijiao:(id)sender {
    
    
    if ([self.info.text length]>0) {
        
       
    UIView *view1=[[UIView alloc] initWithFrame:self.view.bounds];
    view1.backgroundColor=[UIColor grayColor];
    view1.alpha=0.4;
    [self.view addSubview:view1];
    MONActivityIndicatorView *indicatorView = [[MONActivityIndicatorView alloc] init];
    indicatorView.delegate = self;
    indicatorView.numberOfCircles = 3;
    indicatorView.radius = 20;
    indicatorView.internalSpacing = 3;
    indicatorView.center = self.view.center;
    [indicatorView startAnimating];
    [self.view addSubview:indicatorView];
    
    
    
    
    
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    
    //插入评论(username=18285117540, comment_rank 评价星级 id_value=商铺id   content=评论内容 )
    NSString *url=[insertcomment stringByAppendingFormat:@"&username=%@&comment_rank=%ld&id_value=%@&content=%@",acc.custPhone,self.dengji.show_star,self.shop_id,self.info.text];

    [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
        
        NSLog(@"%@",ary);
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"提示" message:ary[@"msg"] delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
        [alert show];
        
        
        
        NSArray *ary123= self.parent.viewControllers;
        for (HLTpinglunTableViewController *order in ary123) {
            
            [order reloadtable];
        }
        
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        [self.navigationController popViewControllerAnimated:YES];
        
        
        
        
    } faliure:^(NSString *error) {
        
        
        
        [indicatorView stopAnimating];
        [view1 removeFromSuperview];
        
        
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"提示" message:@"向服务器请求失败，请重试" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
        [alert show];
        
         [self.navigationController popViewControllerAnimated:YES];
    }];

    }else
    {
        UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"提示" message:@"评论字数不能为空-_-" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
        [alert show];
        
        
        
    }
    
    
    
    
    
    
    
}








@end
